package com.rzblog.project.monitor.logininfor.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.rzblog.framework.aspectj.lang.annotation.Log;
import com.rzblog.framework.aspectj.lang.annotation.RoleInterception;
import com.rzblog.framework.web.controller.BaseController;
import com.rzblog.framework.web.domain.Message;
import com.rzblog.framework.web.page.TableDataInfo;
import com.rzblog.project.monitor.logininfor.domain.Logininfor;
import com.rzblog.project.monitor.logininfor.service.ILogininforService;

/**
 * 系统访问记录
 * 
 * @author ricozhou
 */
@Controller
@RequestMapping("/admin/monitor/logininfor")
public class LogininforController extends BaseController {
	private String prefix = "monitor/logininfor";

	@Autowired
	private ILogininforService logininforService;

	@RequiresPermissions("monitor:logininfor:view")
	@GetMapping()
	public String logininfor() {
		return prefix + "/logininfor";
	}

	@RequiresPermissions("monitor:logininfor:list")
	@GetMapping("/list")
	@ResponseBody
	public TableDataInfo list(Logininfor logininfor) {
		startPage();
		List<Logininfor> list = logininforService.selectLogininforList(logininfor);
		return getDataTable(list);
	}

	@RequiresPermissions("monitor:logininfor:batchRemove")
	@Log(title = "监控管理", action = "登录日志-批量删除")
	@PostMapping("/batchRemove")
	@ResponseBody
	// 拦截指定角色（测试管理员）
	@RoleInterception()
	public Message batchRemove(@RequestParam("ids[]") Long[] ids) {
		int rows = logininforService.batchDeleteLogininfor(ids);
		if (rows > 0) {
			return Message.success();
		}
		return Message.error();
	}
}
